import * as apiService from '@/services/api.js';

import store from '@/store';

/**
 * 佣金概况
 */
const commissionApi = async () => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/commission`, {
    proxyId: store.getters.userId,
  });

  return [result, data];
};

/**
 * 最新存款会员
 */
const latestRechargeApi = async ({page, size}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/latestRecharge`, {
    proxyName: store.getters.username,
    page,
    size
  });

  return [result, data];
};

/**
 * 最新加入会员
 */
const latestRegisterApi = async ({page, size}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/latestRegister`, {
    proxyName: store.getters.username,
    page,
    size
  });

  return [result, data];
};
/**
 * 首充会员列表
 */
const firstRechargeListApi = async ({page, size}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/firstRechargeList`, {
    proxyId: store.getters.userId,
    page,
    size
  });

  return [result, data];
};

/**
 * 注册率分析
 */
const regRateApi = async ({
                            date,
                            proxy,
                            domain,
                          }) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/user/regRate`, {
    proxy: store.getters.username,
    domain,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 资金概况
 */
const funSummaryApi = async ({type,date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/fundSummary`, {
    proxyName: store.getters.username,
    type,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 上分概况
 */
const upAmountSummaryApi = async ({type = 1}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/upAmountSummary`, {
    proxyName: store.getters.username,
    type,
  });

  return [result, data];
};

/**
 * 会员概况
 */
const memberSummaryApi = async ({type,date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/memberSummary`, {
    proxyName: store.getters.username,
    type,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg
  });

  return [result, data];
};

/**
 * 资金概况详细
 */
const fundByTimeApi = async ({type = 1}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/fundByTime`, {
    proxyName: store.getters.username,
    type,
  });

  return [result, data];
};

/**
 * 会员概况详细
 */
const memberByTimeApi = async ({type, date, order, sort, page, size,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/memberByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    type,
    order,
    sort,
    page,
    size,
    isNewReg
  });

  return [result, data];
};

/**
 * 充值金额分时分布
 */
const rechargeByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/rechargeByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 充值人数分时分布
 */
const rechargeUserByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/rechargeUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 提现金额分时分布
 */
const withdrawByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/withdrawByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 提现人数分时分布
 */
const withdrawUserByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/withdrawUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 总投注额分时分布
 */
const bettingAmountByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/bettingAmountByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 总上分额分时分布
 */
const upAmountByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/upAmountByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 上分人数分时分布
 */
const upAmountUserByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/upAmountUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 总用户分时分布
 */
const totalUserByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/totalUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 新注册用户分时分布
 */
const newUserByTimeApi = async ({date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/newUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg,
  });

  return [result, data];
};

/**
 * 活跃用户分时分布
 */
const actUserByTimeApi = async ({date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/actUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg,
  });

  return [result, data];
};

/**
 * 会员输赢分时分布
 */
const bettingWinByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/bettingWinByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 待活跃用户数分时分布
 */
const notActUserByTimeApi = async ({date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/notActUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg,
  });

  return [result, data];
};

/**
 * 有效用户数分时分布
 */
const effectUserByTimeApi = async ({date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/effectUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg,
  });

  return [result, data];
};

/**
 * 登陆用户数分时分布
 */
const loginUserByTimeApi = async ({date,isNewReg}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/loginUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
    isNewReg,
  });

  return [result, data];
};

/**
 * 游戏盈亏 有效投注分时分布
 */
const gameByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/gameByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 有效投注额分时分布
 */
const bettingEffectAmountByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/bettingEffectAmountByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 投注人数分时分布
 */
const bettingUserByTimeApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/bettingUserByTime`, {
    proxyName: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 活跃用户留存率
 */
const actUserApi = async ({date}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/retention/actUser`, {
    proxy: store.getters.username,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });

  return [result, data];
};

/**
 * 新增用户留存 2
 */
const retentionUserApi = async ({date, domain, type = 1}) => {
  const [result, data] = await apiService.post(`${consts.PROXY_PREV}/proxy/retention`, {
    proxy: store.getters.username,
    domain,
    stime: _.result(date, '[0]'),
    etime: _.result(date, '[1]'),
  });
  return [result, data];
};

export {
  latestRechargeApi,
  latestRegisterApi,
  firstRechargeListApi,
  commissionApi,
  funSummaryApi,
  upAmountSummaryApi,
  memberSummaryApi,
  fundByTimeApi,
  memberByTimeApi,

  rechargeByTimeApi,
  rechargeUserByTimeApi,
  withdrawByTimeApi,
  withdrawUserByTimeApi,
  regRateApi,
  bettingAmountByTimeApi,
  upAmountByTimeApi,
  upAmountUserByTimeApi,
  totalUserByTimeApi,
  newUserByTimeApi,
  actUserByTimeApi,
  bettingWinByTimeApi,
  gameByTimeApi,
  bettingEffectAmountByTimeApi,
  bettingUserByTimeApi,
  notActUserByTimeApi,
  effectUserByTimeApi,
  loginUserByTimeApi,
  retentionUserApi,
};
